import requests
from dataclasses import dataclass, field


@dataclass
class Request:
    method: str = None
    host: str = None
    path: str = None
    query: dict = None
    headers: dict = field(default_factory=dict)
    type: str = 'json'
    data: dict = None
    json: dict = None

    def send(self, u_token: str = None):
        if u_token:
            self.headers["X-Litemall-Token"] = u_token

        raw = None

        if self.type == 'json':
            self.headers['Content-Type'] = 'application/json'
        elif self.type == "xxx":
            ...

        requests_response = requests.request(
            method=self.method,
            url=self.host + self.path,
            params=self.query,
            headers=self.headers,
            data=raw,
            auth=None,
            verify=False,
            json=self.json,
        )

        return requests_response
